<?xml version="1.0"?>
<jsp:root 	xmlns:jsp="http://java.sun.com/JSP/Page"
 			xmlns:c="http://java.sun.com/jsp/jstl/core"
 			xmlns="http://www.w3.org/1999/xhtml"
 			version="2.1">
 
 <jsp:directive.page contentType="text/html" pageEncoding="UTF-8" />
 <jsp:directive.page isELIgnored="false" />
 <jsp:output 	omit-xml-declaration="false" 
 			 	doctype-root-element="HTML" 
 				doctype-system="about:legacy-compat" />
 
 <jsp:useBean id="datosLogin" class="es.javamyadmin.beans.LoginBean" scope="session" />
 
 <jsp:useBean id="listaTablesBean" class="es.javamyadmin.beans.ListaTablesBean" scope="session" />
 
 <jsp:setProperty property="user" name="listaTablesBean" value="${datosLogin.usuario}" />
 <jsp:setProperty property="pass" name="listaTablesBean" value="${datosLogin.password}" />
 <jsp:setProperty property="host" name="listaTablesBean" value="${datosLogin.servidor}" />
 <jsp:setProperty property="port" name="listaTablesBean" value="${datosLogin.puerto}" />
 <jsp:setProperty property="database" name="listaTablesBean" value="${param.bd}" />

<html>
<head>

<link rel="icon" href="${pageContext.request.contextPath}/images/favicon.ico" type="image/x-icon"/>
<link rel="shortcut icon" href="${pageContext.request.contextPath}/images/favicon.ico" type="image/x-icon" />

<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/reset.css" media="screen" />
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/java-admin.css" media="screen" />

<title>JavaMyAdmin</title>

</head>

<body>

<div id="contenedor">
	
	<jsp:include page="../includes/sidebar-left.jsp" />
	
	<div id="contenido">
	
		<jsp:include page="../includes/cabecera.jsp" />
		
		<jsp:include page="../includes/menu-superior.jsp" />
		
		<h2>Database <c:out value="${param.bd}"></c:out></h2>
		
		<!-- Errores -->
		<c:if test="${error!=null}"><div class="aviso"><div class="pro_aviso ko"><p><c:out value="${error}"></c:out></p></div></div></c:if>
		
		<c:if test="${ok!=null}"><div class="aviso"><div class="pro_aviso ok"><p><c:out value="${ok}"></c:out></p></div></div></c:if>
		
		<table id="lista-tablas">		
			<tr>
				<th class="inicio">TABLAS</th>
				<th>FILAS</th>
				<th>COTEJAMIENTO</th>
				<th>TIPO</th>
				<th class="fin">ACCIONES</th>
			</tr>
		
			<c:choose>
				<c:when test="${listaTablesBean.tables.size()!=0}">
					<c:forEach var="lista" items="${listaTablesBean.tables}">			
						<tr>
							<td><a href="${pageContext.request.contextPath}/jsp/contenido-tablas-bd.jsp?bd=${param.bd}&amp;tabla=${lista.nombreTable}"><c:out value="${lista.nombreTable}"></c:out></a></td>
							<td align="center"><c:out value="${lista.numFilas}"></c:out></td>
							<td align="center"><c:out value="${lista.cotejamiento}"></c:out></td>
							<td align="center"><c:out value="${lista.tipo}"></c:out></td>
							<td align="center">
								<a href="${pageContext.request.contextPath}/jsp/detalle-tablas-bd.jsp?bd=${param.bd}&amp;tabla=${lista.nombreTable}" title="ver tabla"><img class="margen" src="${pageContext.request.contextPath}/images/icons/ver.png" width="20" height="20" alt="ver"/></a>
								<a href="#" title="editar tabla"><img class="margen" src="${pageContext.request.contextPath}/images/icons/editar.png" width="20" height="20" alt="editar"/></a>
								<a href="${pageContext.request.contextPath}/eliminarTabla?accion=ver&amp;tabla=${lista.nombreTable}" title="eliminar tabla"><img class="margen" src="${pageContext.request.contextPath}/images/icons/eliminar.png" width="20" height="20" alt="eliminar"/></a>
								<a href="${pageContext.request.contextPath}/vaciarTabla?accion=ver&amp;tabla=${lista.nombreTable}" title="vaciar tabla"><img class="margen" src="${pageContext.request.contextPath}/images/icons/vaciar.png" width="20" height="20" alt="vaciar"/></a>
							</td>
						</tr>
					</c:forEach>
				</c:when>
				
				<c:when test="${listaTablesBean.tables.size()==0}">
					<tr>
						<td colspan="5" align="center">No existe ninguna tabla en esta Base de Datos.</td>
					</tr>
				</c:when>
			</c:choose>
			
			
			
	 	</table>
	 	
	 	<form style="margin-top: 30px;" action="${pageContext.request.contextPath}/jsp/crear-tabla.jsp" method="post">
	 		<table>
	 			<tr>
					<td colspan="5"><img class="arrow" src="${pageContext.request.contextPath}/images/arrow.png" />Crear nueva Tabla</td>
				</tr>
				
				<tr>
					<td>Nombre</td>
					<td><input class="campo" type="text" name="nombreTabla"/></td>
					<td>Número de campos</td>
					<td><input class="campo" type="text" name="numCampos"/></td>
					<td><input class="boton" type="submit" value="Crear"/></td>
				</tr>				
	 		</table>
	 	</form>
	 		
	</div>

</div>

</body>
</html>
</jsp:root>